package com.arvin.faceDetect.db

import android.graphics.Bitmap
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import java.util.Date

@Entity(tableName = "faces")
@TypeConverters(Converters::class)
data class FaceEntity(
    @PrimaryKey
    val id: String,
    val name: String,
    val faceImage: Bitmap,
    val faceFeatures: FloatArray,
    val createTime: Long = System.currentTimeMillis()
) {
    fun getDate(): Date = Date(createTime)

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as FaceEntity

        if (id != other.id) return false
        if (name != other.name) return false
        if (faceImage != other.faceImage) return false
        if (!faceFeatures.contentEquals(other.faceFeatures)) return false
        if (createTime != other.createTime) return false

        return true
    }

    override fun hashCode(): Int {
        var result = id.hashCode()
        result = 31 * result + name.hashCode()
        result = 31 * result + faceImage.hashCode()
        result = 31 * result + faceFeatures.contentHashCode()
        result = 31 * result + createTime.hashCode()
        return result
    }
} 